// router/index.js

import modules from './modules'
import {RouterMount,createRouter} from 'uni-simple-router';

const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,  
	routes: [...ROUTES]
});

//全局路由前置守卫
router.beforeEach((to, from, next) => {
	// console.log(to)
	let paths = [
		'/pages/login/login',
		'/pages/index/index',
		'/pages/server/server',
	]
	// 权限列表
	let FunctionList = [];
	if(paths.indexOf(to.path) !== -1) {
		next()
	} else {
		// next()
		let userInfo = uni.getStorageSync('userInfo')
		if(!userInfo) {
			next(
			{
				path: '/pages/login/login',
				NAVTYPE: 'push'
			})
			
		} else {
			next()
			
		}
	}
	
})
// 全局路由后置守卫
router.afterEach((to, from) => {
})

export {
	router,
	RouterMount
}